//
//  JCClubEventModel.m
//  SquashSpark
//
//  Created by 郭吉成 on 2017/11/28.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#import "JCClubEventModel.h"
#import "NSString+Extension.h"

@implementation JCClubEventModel

+ (JCClubEventModel *)creatModelWithData:(NSDictionary *)dataDic{
    JCClubEventModel *model = [JCClubEventModel new];
    model.eventID = [NSString checkIfNullWithString:dataDic[@"ID"]];
    model.clubID = [NSString checkIfNullWithString:dataDic[@"ClubID"]];
    model.content = [NSString checkIfNullWithString:dataDic[@"Content"]];
    model.title = [NSString checkIfNullWithString:dataDic[@"Title"]];
    model.place = [NSString checkIfNullWithString:dataDic[@"Place"]];
    NSMutableArray *icons = [NSMutableArray array];
    NSArray *iconString = [[NSString checkIfNullWithString:dataDic[@"BannerList"]] componentsSeparatedByString:@""];
    for (NSString *string in iconString) {
        NSURL *url = [NSURL URLWithString:string];
        [icons addObject:url];
    }
    model.bannerList = icons.mutableCopy;
    model.startTime = [NSString checkIfNullWithString:dataDic[@"StartTime"]];
    model.endTime = [NSString checkIfNullWithString:dataDic[@"EndTime"]];
    model.creatTime = [NSString checkIfNullWithString:dataDic[@"CreateTime"]];
    return model;
}

+ (NSArray <JCClubEventModel *>*) creatFindClubList:(NSArray *)sourceArray{
    NSMutableArray *array = [NSMutableArray array];
    for (NSDictionary *dic in sourceArray) {
        [array addObject:[self creatModelWithData:dic]];
    }
    return array.mutableCopy;
}

@end
